package com.jingbit.ai.base;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.fragment.app.Fragment;

import com.jingbit.ai.helper.DeviceHelper;

/**
 * Fragment基类 定义统一回调接口 生命周期监听
 * 
 */
public class BaseFragment extends Fragment {
	
	public BaseFragment() {
		super();
	}

	public static BaseFragment newInstance(int type) {
		BaseFragment newFragment = new BaseFragment();
		Bundle bundle = new Bundle();
		bundle.putInt("type", type);
		newFragment.setArguments(bundle);
		return newFragment;
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		BaseApp.registerListener(this);
	}
	
	public void startActivity(Class<?> cls){
		Intent intent=new Intent(getActivity(),cls);
		startActivity(intent);
	}
	
	public void startActivity(Class<?> cls,Bundle bundle){
		Intent intent=new Intent(getActivity(),cls);
		intent.putExtras(bundle);
		startActivity(intent);
	}
	
	public void startActivity(Class<?> cls, int reqCode) {
		startActivityForResult(new Intent(getActivity(), cls), reqCode);
	}
	
	public void doClick(View view){
	}

	@Override
	public void onPause() {
		super.onPause();
	}

	@Override
	public void onResume() {
		super.onResume();
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
		BaseApp.unregisterListener(this);
	}
}
